import { basicDictSlotList,basicSlotDialogList,basicSlotQaList} from '@/services/basiccapacity';

export default {
  namespace: 'service',

  state: {
   
  },
  effects: {
    *basicDictSlotList({ payload, callback }, { call, put }) { // 实体管理 使用中词槽列表
      const response = yield call(basicDictSlotList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicSlotDialogList({ payload, callback }, { call, put }) { // 词槽管理 词槽使用中的多轮列表
      const response = yield call(basicSlotDialogList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *basicSlotQaList({ payload, callback }, { call, put }) { // 词槽管理 词槽使用中的知识点列表
      const response = yield call(basicSlotQaList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    fetchb(state,{payload}){
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
        total:'',
        list:[]
      };
    },
  },
};
